﻿using System.ComponentModel;
using DevExpress.XtraBars.Docking2010.Views;
using XCI.Helper;
using XCI.Sys;

namespace XCI.Windows.Widgets
{
    [ToolboxItem(false)]
    [WidgetCaption("当前用户")]
    public partial class CurrentUserWidget : BaseWidget
    {
        public CurrentUserWidget()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 初始化控件
        /// </summary>
        /// <param name="document">文档对象</param>
        public override void Init(BaseDocument document)
        {
            var cuser = SysApp.CurrentUser;
            if (cuser == null)
            {
                labelControl1.Text = "<size=14>未登陆</size>";
            }
            else
            {
                labelControl1.Text = $"<size=14>账户：<color=red><b>{cuser.Name}({cuser.Account})</b></color>" +
                                     $"<br>机构：{cuser.DeptName}" +
                                     $"<br>最后登陆时间：{DateTimeHelper.FormatDateHasMinute(cuser.LastVisitDateTime)}</size>";
            }
        }
    }
}